home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.pro;
-
- import java.io.EOFException;
- import java.util.Properties;
- import java.util.Vector;
- import symantec.itools.db.net.NetData;
- import symantec.itools.db.net.RemoteObject;
- import symjava.sql.SQLException;
-
- public class MultiView {
- private RelationView _rootRV;
- private RemoteObject _messgr;
- private byte _rvCurrentID = 0;
- private int _proxyID;
- RecordTree _rootRecord = new RecordTree();
- boolean _closed = false;
- private Properties _rootRVCtorProperties;
- final int METHOD_fetchRecords;
- final int METHOD_OnDataChange = 1;
- final int METHOD_save = 2;
- final int METHOD_isDataChanged = 3;
- final int METHOD_undoChanges = 4;
- final int METHOD_undoRecord = 5;
- final int METHOD_deleteRecord = 6;
- final int METHOD_getNewRecord = 7;
- final int METHOD_close = 8;
- final int METHOD_getStream = 9;
- final int METHOD_restart = 10;
-
- MultiView(Session session, Vector ctorParams, ConnectionInfo conn) throws SQLException {
- NetData d = (NetData)ctorParams.elementAt(0);
-
- int id;
- try {
- id = d.getInt();
- } catch (EOFException e) {
- throw new SQLException(((Throwable)e).getMessage());
- }
-
- this._proxyID = id;
- this._messgr = new RemoteObject("CSCLMultiView", id, session.getClientSession());
- ctorParams.removeElementAt(0);
- this.saveRootRVProperties(session, ctorParams, conn);
- }
-
- private void saveRootRVProperties(Session session, Vector ctorParams, ConnectionInfo conn) {
- this._rootRVCtorProperties = new Properties();
- this._rootRVCtorProperties.put("session", session);
- this._rootRVCtorProperties.put("ctorParams", ctorParams);
- this._rootRVCtorProperties.put("conn", conn);
- this.getNextLevelID();
- }
-
- Properties getRootRVCtorProperties() {
- return this._rootRVCtorProperties;
- }
-
- void setRootRelView(RelationView rv) {
- this._rootRV = rv;
- }
-
- byte getNextLevelID() {
- byte var10002 = this._rvCurrentID;
- this._rvCurrentID = (byte)(var10002 + 1);
- return var10002;
- }
-
- byte getCurrentLevelID() {
- return this._rvCurrentID;
- }
-
- private void checkClosed() throws SQLException {
- if (this._closed) {
- throw new SQLException("MultiView has been closed");
- }
- }
-
- void freeRecordBuffer(boolean fullReset) throws SQLException {
- this.checkClosed();
- this._rootRecord.freeRecordBlocks();
- this._rootRecord = new RecordTree();
- this.getRootRelView().resetRecordSet(fullReset);
- }
-
- public synchronized void close() throws SQLException {
- this.checkClosed();
- this._messgr.invokeMethod(8);
- this.freeRecordBuffer(true);
- this._messgr.disable();
- this._closed = true;
- }
-
- public RelationView getRootRelView() throws SQLException {
- if (this._rootRV == null) {
- ConnectionInfo conn = (ConnectionInfo)this._rootRVCtorProperties.get("conn");
- this._rootRV = new RelationView(this, (byte)0, conn);
- }
-
- return this._rootRV;
- }
-
- public boolean isDataChanged() throws SQLException {
- this.checkClosed();
- if (!this.getRootRelView().notifySetData()) {
- return true;
- } else {
- Vector results = this._messgr.invokeMethod(3);
- NetData d = (NetData)results.elementAt(0);
-
- try {
- return d.getBool();
- } catch (EOFException e) {
- throw new SQLException(((Throwable)e).getMessage());
- }
- }
- }
-
- public void save() throws SQLException {
- this.checkClosed();
- if (this.getRootRelView().notifySetData()) {
- this._messgr.invokeMethod(2);
- this.freeRecordBuffer(false);
- }
-
- }
-
- public void restart() throws SQLException {
- this.checkClosed();
- this._messgr.invokeMethod(10);
- this.freeRecordBuffer(false);
- }
-
- public void undoDataChanges() throws SQLException {
- this.checkClosed();
- this._messgr.invokeMethod(4);
- this.freeRecordBuffer(false);
- }
-
- RecordSet getRecordSet(RelViewPos pos) throws SQLException {
- this.checkClosed();
- pos.setMVRemObj(this._messgr);
- return this._rootRecord.getRecordSet(pos.reset());
- }
- }
-